package com.xigua._递归;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
 * 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢？
 * @date 2022/3/923:55
 */
public class _70_爬楼梯 {

    public int climbStairs(int n) {
        while (n==1) return 1;
        int first = 1;
        int second = 2;
        int tem = 0;
        for (int i = 3; i <= n; i++) {
            tem =second;
            second = first+second;
            first = tem;

        }
        return second;
    }
}
